import request from "@/utils/request";

export function exportExcel(name, url, data) {
  request({
    url,
    method: "post",
    data,
    responseType: "blob",
  }).then((res) => {
    const url = window.URL.createObjectURL(new Blob([res]));
    let link = document.createElement("a");
    link.style.display = "none";
    link.href = url;
    link.setAttribute("download", `${name}.xlsx`);
    document.body.appendChild(link);
    link.click();
    URL.revokeObjectURL(link.href); // 释放URL 对象
    document.body.removeChild(link);
    link = null;
  });
}
